package net.togogo.egouweb1238.core.service.order.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.togogo.egouweb1238.common.page.Pagination;
import net.togogo.egouweb1238.core.dao.order.DetailDao;
import net.togogo.egouweb1238.core.domain.order.Detail;
import net.togogo.egouweb1238.core.query.order.DetailQuery;
import net.togogo.egouweb1238.core.service.order.IDetailService;

/**
 * 订单子项(订单详情)
 * @author stone
 */
@Service
@Transactional
public class DetailServiceImpl implements IDetailService {

	@Resource
	private DetailDao detailDao;

	/**
	 * 插入数据库
	 * 
	 * @return
	 */
	public Integer addDetail(Detail detail) {
		return detailDao.addDetail(detail);
	}

	/**
	 * 根据主键查找
	 */
	@Transactional(readOnly = true)
	public Detail getDetailById(Integer id) {
		return detailDao.getDetailById(id);
	}
	
	@Transactional(readOnly = true)
	public List<Detail> getDetailsByIds(List<Integer> idList) {
		return detailDao.getDetailsByIds(idList);
	}

	/**
	 * 根据主键删除
	 * 
	 * @return
	 */
	public Integer deleteById(Integer id) {
		return detailDao.deleteById(id);
	}

	public Integer deleteByIds(List<Integer> idList) {
		return detailDao.deleteByIds(idList);
	}

	/**
	 * 根据主键更新
	 * 
	 * @return
	 */
	public Integer updateDetailById(Detail detail) {
		return detailDao.updateDetailById(detail);
	}
	
	@Transactional(readOnly = true)
	public Pagination getDetailListWithPage(DetailQuery detailQuery) {
		Pagination p = new Pagination(detailQuery.getPageNo(),detailQuery.getPageSize(),detailDao.getDetailListCount(detailQuery));
		p.setList(detailDao.getDetailListWithPage(detailQuery));
		return p;
	}
	
	@Transactional(readOnly = true)
	public List<Detail> getDetailList(DetailQuery detailQuery) {
		return detailDao.getDetailList(detailQuery);
	}
}
